﻿

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}

<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li><a href="#">首页</a></li>
        <li><a href="#">会议管理</a></li>
    </ul>
</div>
<div class="formbody">
    <ul class="seachform">
        <li>
            <label>会议名称:</label><input name="" type="text" class="dfinput" id="Name" />
        </li>

        <li>
            <label>&nbsp;</label>
            <input name="" id="ok" type="button" class="scbtn" value="查询" />
            <label>&nbsp;</label>
            <input name="" id="add" type="button" class="scbtn" value="新建会议" />

        </li>
    </ul>


</div>
<div class="table-content">
    <table id="table" class="tablelist"></table>
</div>

<script type="text/javascript">
    $(function () {

        var $table = $('#table'), $ok = $('#ok');
        $ok.click(function () {
            $table.bootstrapTable('refresh');
        });
        function queryParams(params) {
            $('#toolbar').find('input[name]').each(function () {
                params[$(this).attr('name')] = $(this).val();
            });
            params["Name"] = $("#Name").val();
            return params;
        }

        function responseHandler(res) {
            return res.rows;
        }
        $('#table').bootstrapTable({
            url: '/Meet/GetMeetList',
            //url: '/api/Document/GetList',
            pagination: true,
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 10,                       //每页的记录行数（*）
            pageList: [10],        //可供选择的每页的行数（*）
            //search: true,   //是否显示表格搜索，此搜索是客户端搜索
            striped: true,
            queryParams: queryParams,
            //responseHandler:responseHandler,
            toolbar: "#toolbar",
            columns: [{
                field: 'Number',
                title: '序号',
                align: 'center',
                width: 50,
                formatter: function (value, row, index) {
                    //return index + 1;
                    var pageSize = $('#table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                    var pageNumber = $('#table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                    return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                }
            }, {
                field: 'MeetName',
                title: '会议名称'
            }, {
                field: 'MeetRemark',
                title: '备注'
            }, {
                field: 'AllUser',
                title: '应到人数'
            },{
                field: 'RealUser',
                title: '实到人数'
            },
            {
                field: 'CreatedTimeStr',
                title: '提交时间'
            }, {
                field: 'Id',
                title: '操作',
                formatter: function (value, row) {
                    return '<a  onclick="fnClearMobile(\'' + value + '\')" class="tablelink">清空设备</a>   <a  onclick="fnEidt(\'' + value + '\')" class="tablelink">修改</a>     <a onclick="fnDelete(\'' + value + '\')" class="tablelink">删除</a>  <a onclick="fnView(\'' + value + '\')" class="tablelink">查看</a>';
                }
            }, ]
        });
        $("#add").click(function () {
            window.layer.open({
                type: 2,
                 area: ['600px', '500px'],
                 fixed: true,
                 maxmin: true,
                content: '@Url.Action("MeetView", "Meet")'
            });

        })
    })
    function fnEidt(id) {
        window.layer.open({
            type: 2,
            area: ['600px', '500px'],
            fixed: true,
            maxmin: true,
            content: '@Url.Action("MeetView", "Meet")?Id='+id
        });
    }
    function fnDelete(id) {
        layer.confirm('确定删除吗？', {
            btn: ['确定', '取消'] //按钮
        }, function (index) {
            $.post("../Meet/MeetDelete", { Id: id }, function (result) {
                if (result.state == 1) {
                    layer.msg('操作成功');
                    layer.close(index);
                    $("#table").bootstrapTable('refresh');
                }
                else {
                    parent.layer.msg(result.message);
                }
            })
        }, function (index) {
            layer.close(index);
        });

    }
    function fnClearMobile(id) {
        window.layer.confirm('确定清空设备吗？', {
            btn: ['确定', '取消'] //按钮
        }, function (index) {
            $.post("../Meet/ClearMeet", { Id: id }, function (result) {
                if (result.state == 1) {
                    layer.msg('操作成功');
                    layer.close(index);
                    $("#table").bootstrapTable('refresh');
                }
                else {
                    parent.layer.msg(result.message);
                }
            })
        }, function (index) {
            layer.close(index);
        });
    }
    function fnView(id)
    {
        window.open('@Url.Action("CompanyIndex", "Visitor")?MeetId=' + id);
      
    }


</script>
